$tfam = $ARGV[0];
chomp($tfam);
$qc = $ARGV[1];
chomp($qc);
$qc_new = $ARGV[2];
chomp($qc_new);
#open(BUFF,$tfam) or die "no file tfam $tfam found\n";
#while(<BUFF>)
#{
#	chomp($_);
#	@a = split(" ",$_);
#	$hash{$a[1]} =1;
#}
open(BUFF,$qc) or die "no file qc $qc found\n";
open(WRBUFF,">$qc_new") or die "not able to write the file\n";
#$line = <BUFF>;
#print WRBUFF $line;
while(<BUFF>)
{
        chomp($_);
        @a = split("\t",$_);
	if($a[1] eq "Y")
	{
		#print WRBUFF $_."\n";
		$hash{$a[0]} =$_ ;
	}
}
open(BUFF,$tfam) or die "no file tfam $tfam found\n";
while(<BUFF>)
{
       chomp($_);
       @a = split(" ",$_);
       if(exists($hash{$a[1]}))
	{
		print WRBUFF $hash{$a[1]}."\n";
	}
	else
	{
		die " no QC found die for $a[1]\n";
	}
}

